﻿<%@ WebHandler Language="C#" Class="huoqutupian" %>

using System;
using System.Web;
using System.IO;
using KeaoBase;

public class huoqutupian : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        try
        {
            string fileName= context.Request.QueryString["fileName"];
            if (string.IsNullOrEmpty(fileName))
            {
                context.Response.Write("js/themes/noPic.jpg");
            }
            else
            {
                fileName = fileName.Replace("视频截图", "Image");
                string filePathName = string.Format("{0}{1}",context.Server.MapPath("").Replace("handler",""),fileName);
                if (File.Exists(filePathName))
                {
                    FileInfo f = new FileInfo(filePathName);
                    if (f.Length < 20000)
                    {
                        context.Response.Write("js/themes/noPic.jpg");
                    }
                    else
                    {
                        context.Response.Write(fileName.Replace("\\", "/"));
                    }
                }
                else
                {
                    context.Response.Write("js/themes/noPic.jpg");
                }
            }

        }
        catch(Exception err)
        {
            KeaoUtils.LogTxt(string.Format("获取图片信息异常。{0}", err.Message));
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}